/*
 * Copyright 2010 J Patrick Davenport
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package v4view.web;

import junit.framework.Assert;

import org.junit.Test;

/**
 * @author J Patrick Davenport
 *
 */
public class HtmlObjectTests extends HtmlObject {
	private HtmlObject	obj	= new HtmlObject();

	@Test
	public void checkAdvancedProperties() {
		// Let's try a more TDD approach to creating the properties.
		String archive = this.obj.getArchive();
		Assert.assertNull(archive);
		archive = "some.jar";
		HtmlObject o = this.obj.setArchive(archive);
		Assert.assertEquals(this.obj, o);
		Assert.assertEquals(archive, this.obj.getArchive());

		String codeType = this.obj.getCodeType();
		Assert.assertNull(codeType);
		codeType = "text/css";
		o = this.obj.setCodeType(codeType);
		Assert.assertEquals(o, this.obj);
		Assert.assertEquals(codeType, this.obj.getCodeType());
	}

	@Test
	public void checkBasicProperties() {
		// Make sure that everything is properly clean to start.
		String classid = this.obj.getClassid();
		Assert.assertNull(classid);
		String codebase = this.obj.getCodebase();
		Assert.assertNull(codebase);
		String height = this.obj.getHeight();
		Assert.assertNull(height);
		String name = this.obj.getName();
		Assert.assertNull(name);
		String type = this.obj.getType();
		Assert.assertNull(type);
		String width = this.obj.getWidth();
		Assert.assertNull(width);

		// Check the sets.
		classid = "clsid:8675309";
		final HtmlObject setClassid = this.obj.setClassid(classid);
		Assert.assertEquals(this.obj, setClassid);
		Assert.assertEquals(classid, this.obj.getClassid());

		codebase = "codebase.class";
		final HtmlObject setCodebase = this.obj.setCodebase(codebase);
		Assert.assertEquals(this.obj, setCodebase);
		Assert.assertEquals(codebase, codebase);

		height = "23%";
		final HtmlObject setHeight = this.obj.setHeight(height);
		Assert.assertEquals(this.obj, setHeight);
		Assert.assertEquals(height, this.obj.getHeight());

		name = "myName";
		final HtmlObject setName = this.obj.setName(name);
		Assert.assertEquals(this.obj, setName);
		Assert.assertEquals(name, this.obj.getName());

		type = "text/app";
		final HtmlObject setType = this.obj.setType(type);
		Assert.assertEquals(this.obj, setType);
		Assert.assertEquals(type, this.obj.getType());

		width = "50%";
		final HtmlObject setWidth = this.obj.setWidth(width);
		Assert.assertEquals(this.obj, setWidth);
		Assert.assertEquals(width, this.obj.getWidth());
	}
}
